/** 
  *@CopyRight(c)2009 company Co.Ltd. 
  *@All right reserved.
  *@module name: App.Base.SystemManage.SystemMenusManage
  *@description:
  *
  *@author: lugj
  *@version: 1.0
  *@date: 2009/06/10
  *@last date: 2009/07/15
  *@history:
    1.
    2.
  *@bugs:
    1. 
    2. 
  *
*/ 

Ext.namespace("App.Base.SystemManage");

//SystemMenusManage Class
//config: {id: , }
App.Base.SystemManage.SystemMenusManage = function(config){

	//generating the global unique id.
	this.config = config;

	this.MODULE_ID = (typeof(this.config) == 'undefined') ? null : this.config.id;

	this.MODULE_ID = (this.MODULE_ID == null) ? App.Base.Common.func.getSystemDateTimeMark() : this.MODULE_ID;
	
	this.MODULE_ID = 'SYSMENUSMGR' + this.MODULE_ID;

	//defined constants.

	this.OpCmd = App.Base.common.param.OP_CMD_NONE;

	this.win = null;

	this.curSelMenuId = App.Base.common.param.INVALIDATE_ID;
	this.curSelMenuOldPId = App.Base.common.param.INVALIDATE_ID;
	this.curSelMenuNewPId = App.Base.common.param.INVALIDATE_ID;

	//
	this.treeClick = function(node){
		node.select();

		if (node == null)
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统发生错误：TreePanel选择的当前菜单项节点node为NULL",
					icon: Ext.MessageBox.ERROR
				});
			return;
		}

		if (this.asyncTreeNode.id == node.id)
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统不允许操作顶级根菜单项",
					icon: Ext.MessageBox.ERROR
				});
			this.form.getForm().reset();
			return;
		}

		this.curSelMenuId = node.id.substr(0, node.id.length - this.MODULE_ID.length);
		this.curSelMenuOldPId = node.parentNode.id.substr(0, node.parentNode.id.length - this.MODULE_ID.length);
		
		//这里初始化菜单项配置界面
		Ext.getCmp('menuName' + this.MODULE_ID).setRawValue(node.text);
		Ext.getCmp('menuParentId' + this.MODULE_ID).setRawValue(this.curSelMenuOldPId + App.Base.common.param.SPLIT_CHARS_UNDELINE + node.parentNode.text);
		Ext.getCmp('menuDesc' + this.MODULE_ID).setRawValue(node.attributes['qtip']);
		Ext.getCmp('leafNodeFlag' + this.MODULE_ID).setValue(node.isLeaf());
		Ext.getCmp('menuNavUrl' + this.MODULE_ID).setRawValue(node.attributes['actionModuleConfig']);
		Ext.getCmp('expandImgUrl' + this.MODULE_ID).setRawValue(node.attributes['expandIcon']);
		Ext.getCmp('normalImgUrl' + this.MODULE_ID).setRawValue(node.attributes['icon']);
		Ext.getCmp('displayRankIndex' + this.MODULE_ID).setRawValue(node.attributes['displayRankIndex']);
		Ext.getCmp('sysHoldFlag' + this.MODULE_ID).setValue(node.attributes['sysHoldFlag'].trim() == '1' ? true:false);
		Ext.getCmp('menuDisplayFlag' + this.MODULE_ID).setValue(node.attributes['menuDisplayFlag'].trim() == '1' ? true:false);
	};

	this.treeRefresh = function(){
		var node = null;

		if (this.OpCmd == App.Base.common.param.OP_CMD_ADD)
		{
			node = this.tree.getNodeById(this.curSelMenuNewPId + this.MODULE_ID);
			if (!(typeof(node) == 'undefined' || node == null))
			{
				node.reload();
			}
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_MODIFY)
		{
			node = this.tree.getNodeById(this.curSelMenuId + this.MODULE_ID);
			if (!(typeof(node) == 'undefined' || node == null))
			{
				node.remove();
			}

			node = this.tree.getNodeById(this.curSelMenuNewPId + this.MODULE_ID);
			if (!(typeof(node) == 'undefined' || node == null))
			{
				node.reload();
			}
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			node = this.tree.getNodeById(this.curSelMenuId + this.MODULE_ID);
			if (!(typeof(node) == 'undefined' || node == null))
			{
				node.remove();
			}
		}	
	};

	this.winHandler = function(win, node){
		if (win.action == '2')
		{
			this.OpCmd = App.Base.common.param.OP_CMD_NONE;
			return;
		}

		if (node == null)
		{
			return;
		}

		var nodeId = node.id.substr(node.id, node.id.length - win.MODULE_ID.length);

		//删除
		if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			if (App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_ID == nodeId)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
						title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
						msg: "系统不允许删除顶级根菜单项",
						icon: Ext.MessageBox.ERROR
					});
				this.OpCmd = App.Base.common.param.OP_CMD_NONE;
				this.form.getForm().reset();
				return;
			}			

			if (win.tree.getNodeById(nodeId + win.MODULE_ID).hasChildNodes())
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统不允许删除有子菜单项的菜单项",
					icon: Ext.MessageBox.ERROR
				});	
				this.OpCmd = App.Base.common.param.OP_CMD_NONE;
				this.form.getForm().reset();
				return null;
			}

			Ext.MessageBox.show({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: '确定要删除系统菜单项 [' + node.text + ']',
				buttons: Ext.MessageBox.YESNO,
				icon: Ext.MessageBox.QUESTION,
				fn: function(btn){
					if (btn == 'yes')
					{
						this.curSelMenuId = nodeId;
						this.curSelMenuOldPId = node.parentNode.id.substr(node.parentNode.id, node.parentNode.id.length - win.MODULE_ID.length);
						this.doRequest();
					}
					else
					{
						this.OpCmd = App.Base.common.param.OP_CMD_NONE;
					}
				},
				scope: this
			});	

			return;
		}
		
		if (node.isLeaf())
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: "菜单项的上级菜单不能为菜单项节点",
				icon: Ext.MessageBox.ERROR
			});

			return;
		}

		//新增/修改
		Ext.getCmp('menuParentId' + this.MODULE_ID).setRawValue(nodeId + App.Base.common.param.SPLIT_CHARS_UNDELINE + node.text);	
	};

	this.getRequestParams = function(){
		
		this.curSelMenuNewPId = Ext.getCmp('menuParentId' + this.MODULE_ID).getRawValue().trim().split(App.Base.common.param.SPLIT_CHARS_UNDELINE)[0];

		var menuId = this.curSelMenuId;
		var menuName = Ext.getCmp('menuName' + this.MODULE_ID).getRawValue().trim();	
		var menuParentId = this.curSelMenuNewPId;	
		var menuDesc = Ext.getCmp('menuDesc' + this.MODULE_ID).getRawValue().trim();
		var leafNodeFlag = Ext.getCmp('leafNodeFlag' + this.MODULE_ID).getValue() == true ? '1' : '0';
		var menuNavUrl = Ext.getCmp('menuNavUrl' + this.MODULE_ID).getRawValue().trim();	
		var expandImgUrl = Ext.getCmp('expandImgUrl' + this.MODULE_ID).getRawValue().trim();	
		var normalImgUrl = Ext.getCmp('normalImgUrl' + this.MODULE_ID).getRawValue().trim();	
		var displayRankIndex = Ext.getCmp('displayRankIndex' + this.MODULE_ID).getRawValue().trim();	
		var sysHoldFlag = Ext.getCmp('sysHoldFlag' + this.MODULE_ID).getValue() == true ? '1' : '0';
		var menuDisplayFlag = Ext.getCmp('menuDisplayFlag' + this.MODULE_ID).getValue() == true ? '1' : '0';

		//这里验证数据正确合理性
		var validate = true;

		if (leafNodeFlag == '1' ? App.Base.Common.func.isEmptyString(menuNavUrl) : App.Base.Common.func.isEmptyString(expandImgUrl))
		{
			validate = false;
		}

		if (this.curSelMenuNewPId == App.Base.common.param.INVALIDATE_ID)
		{
			validate = false;
		}

		if (!(validate && this.form.getForm().isValid()))
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: '菜单项数据格式填写不正确',
				icon: Ext.MessageBox.ERROR
			});
			this.OpCmd == App.Base.common.param.OP_CMD_NONE;
			return null;		
		} 

		if (Ext.getCmp('menuParentId' + this.MODULE_ID).getValue().trim().length == 0)
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: '请选择模块上级菜单分类',
				icon: Ext.MessageBox.ERROR
			});
			this.OpCmd == App.Base.common.param.OP_CMD_NONE;
			return null;		
		} 

		//
		if (this.OpCmd == App.Base.common.param.OP_CMD_MODIFY)
		{
			if (this.tree.getSelectionModel().getSelectedNode() == null)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "请选择要进行修改的菜单项节点",
					icon: Ext.MessageBox.ERROR
				});	
				return null;
			}

			if (menuId == App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_ID)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
						title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
						msg: "系统不允许操作菜单目录树的菜单项根节点",
						icon: Ext.MessageBox.ERROR
					});
				return null;
			}

			if (menuId == menuParentId)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "菜单项的上级菜单项不能为本菜单节点",
					icon: Ext.MessageBox.ERROR
				});	
				return null;
			}

			if (Ext.getCmp('leafNodeFlag' + this.MODULE_ID).getValue() && this.tree.getNodeById(menuId + this.MODULE_ID).hasChildNodes())
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统不允许修改有子菜单的菜单项为菜单节点类型",
					icon: Ext.MessageBox.ERROR
				});	
				this.form.getForm().reset();
				return null;
			}
		}

		//
		params = 'SYSTEM_MENUS_OPERATION_COMMAND=' + encodeURIComponent(this.OpCmd) 
			+ '&MENU_ID=' + encodeURIComponent(menuId)
			+ '&MENU_PARENT_ID=' + encodeURIComponent(menuParentId)
			+ '&MENU_NAME=' + encodeURIComponent(menuName)
			+ '&MENU_DESC=' + encodeURIComponent(menuDesc)
			+ '&LEAF_NODE_FLAG=' + encodeURIComponent(leafNodeFlag)
			+ '&MENU_NAV_URL=' + encodeURIComponent(menuNavUrl)
			+ '&EXPAND_IMG_URL=' + encodeURIComponent(expandImgUrl)
			+ '&NORMAL_IMG_URL=' + encodeURIComponent(normalImgUrl)
			+ '&DISPLAY_RANK_INDEX=' + encodeURIComponent(displayRankIndex)
			+ '&MENU_DISPLAY_FLAG=' + encodeURIComponent(menuDisplayFlag)
			+ '&SYS_HOLD_FLAG=' + encodeURIComponent(sysHoldFlag);
		
		return params;
	};

	this.handlerSuccess = function(response){
		Ext.getBody().unmask();
		//var result = decodeURIComponent(params.response.responseText);

		var result = Ext.decode(response.responseText);
		//{returnCode: , msg: );
		
		var icon = (result.returnCode == App.Base.common.param.REQ_SUCCESS) ? Ext.MessageBox.INFO:Ext.MessageBox.ERROR;

		App.Base.Common.func.MESSAGEBOX_SHOW({
			title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
			//msg: result.returnCode + '：'+ result.msg,
			msg: result.msg,
			icon: icon
		});
		
		if (result.returnCode == App.Base.common.param.REQ_SUCCESS)
		{
			//自动更新系统菜单目录树

			if (this.config.handler)
			{
				//this.handler.apply(this.scope || this, arguments);
				this.config.handler.call(this.config.scope || this, {
					object: this, 
					OpCmd: this.OpCmd, 
					curSelMenuId: this.curSelMenuId, 
					curSelMenuOldPId: this.curSelMenuOldPId, 
					curSelMenuNewPId: this.curSelMenuNewPId
				});
			}

			this.treeRefresh();
		}
		
		//
		this.OpCmd = App.Base.common.param.OP_CMD_NONE;

		this.curSelMenuId = App.Base.common.param.INVALIDATE_ID;
		this.curSelMenuOldPId = App.Base.common.param.INVALIDATE_ID;
		this.curSelMenuNewPId = App.Base.common.param.INVALIDATE_ID;

		this.form.getForm().reset();
	};

	this.handlerFailure = function(){
		App.Base.Common.func.MESSAGEBOX_SHOW({
			title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
			msg: '服务器请求操作失败，请稍候重试',
			icon: Ext.MessageBox.ERROR
		});	
	};

	this.doRequest = function(){
		var params = null;
		if (this.OpCmd == App.Base.common.param.OP_CMD_ADD || this.OpCmd == App.Base.common.param.OP_CMD_MODIFY)
		{
			params = this.getRequestParams();
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			params = 'SYSTEM_MENUS_OPERATION_COMMAND=' + encodeURIComponent(this.OpCmd) 
				+ '&MENU_ID=' + encodeURIComponent(this.curSelMenuId)
				+ '&MENU_PARENT_ID=' + encodeURIComponent(this.curSelMenuOldPId);
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_GENERATE)
		{
			params = 'SYSTEM_MENUS_OPERATION_COMMAND=' + encodeURIComponent(this.OpCmd);
		}

		if (params != null)
		{
			App.Base.Common.func.request({
				method: 'POST',
				url: App.Base.common.param.SYSMENUMGR_OPERATION_DATAURL,
				success: this.handlerSuccess,
				failure: this.handlerFailure,
				scope: this,
				params: params
			});
		}	
	};

	this.createSysSelUpMenusWin = function(){
		var title = '选择上级菜单分类';
		var leaf = '0';
		if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			title = '删除菜单项';
			leaf = '2';
		}
		new App.Base.SystemManage.SystemSelectTreeWindow({
			id: this.MODULE_ID,
			title: title,
			leaf: leaf,
			params: '2',
			asyncTreeNode: {
				id: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_ID,
				text: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_NORMAL_TITLE,
				icon: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_ICON_URL,
				expandIcon: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_EXPANDICON_URL,
				qtip: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_QTIP,
				singleClickExpand: true
			},
			dataUrl: App.Base.common.param.SYSTEM_TREEPANEL_ASYNC_TREELOADER_DATAURL,
			handler: function(o, node){
				if (o.action == App.Base.common.param.BUTTON_ACTION_OK)
				{
					this.winHandler(o, node);
				}
				else
				{
					this.OpCmd = App.Base.common.param.OP_CMD_NONE;
				}
			},
			scope: this
		}).getMainPanel().show();
	};

	//tree
	this.asyncTreeNode = new Ext.tree.AsyncTreeNode({
		id: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_ID + this.MODULE_ID,
		text: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_NORMAL_TITLE,

		icon: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_ICON_URL,
		expandIcon: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_EXPANDICON_URL,
		qtip: App.Base.common.param.SYSTEM_MAIN_TREEPANEL_ROOTNODE_QTIP
	});
	
	this.tree = new Ext.tree.TreePanel({
		id: 'tree' + this.MODULE_ID,

		autoScroll: true,

		root: this.asyncTreeNode,

		loader: new Ext.tree.TreeLoader({
			dataUrl: App.Base.common.param.SYSTEM_TREEPANEL_ASYNC_TREELOADER_DATAURL,
			baseParams: {
				module: this.MODULE_ID
			}
		})
	});

	this.tree.on("beforeexpandnode", function(node){
		if (node != null)
		{
			node.select();
			node.setIcon(node.attributes['expandIcon']);				
		}
	});

	this.tree.on("beforecollapsenode", function(node){
		if (node != null)
		{
			node.select();
			node.setIcon(node.attributes['icon']);				
		}
	});

	this.tree.on("click", this.treeClick, this);

    this.contextmenu = new Ext.menu.Menu({
		id: 'contextmenu' + this.MODULE_ID,
		items: [{
			id: 'ctxExpand' + this.MODULE_ID,
			text: '展开目录节点',
			iconCls: 'x-menu-mainframe-expand'
		}, {
			id: 'ctxCollapse' + this.MODULE_ID,
			text: '折叠目录节点',
			iconCls: 'x-menu-mainframe-collapse'
		}, '-', {
			id: 'ctxReload' + this.MODULE_ID,
			text: '重载目录节点',
			iconCls: 'x-menu-mainframe-refresh'
		}],
		listeners: {
			click: function(menu, menuItem, e){
				this.contextmenu.hide();
			   
				var menuItemId = menuItem.getId();
				
				var node = this.tree.getSelectionModel().getSelectedNode();

				switch(menuItemId)
				{
					case 'ctxExpand' + this.MODULE_ID:
						node.expand();
						break;
					case 'ctxCollapse' + this.MODULE_ID:
						node.collapse();
						break;
					case 'ctxReload' + this.MODULE_ID:
						node.reload();
						break;
					default:
						break;
				}
					   
			}, 
			scope: this
		}
	});
            
	this.tree.on("contextmenu", function(node, e){
		e.preventDefault();
		
		node.select();

		if (!node.isLeaf())
		{
			this.contextmenu.showAt(e.getXY());
		}
	}, this);

	this.asyncTreeNode.expand();

    this.form = new Ext.FormPanel({
		id: 'form' + this.MODULE_ID,

		autoDestroy: true,

		border: false,

		tbar: new Ext.Toolbar({
			id: 'tbar' + this.MODULE_ID ,
			border: false,
			items : ['->', '-', {
				id: 'tbarMenusRefresh' + this.MODULE_ID,
				text:'<font color="red">更新菜单权限</font>',
				iconCls: 'x-menu-mainframe-refresh',
				tooltip: {title: '提示：', text: '更新菜单权限'},
				handler: function(){
					Ext.MessageBox.show({
						title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
						msg: '确定要更新系统菜单权限',
						buttons: Ext.MessageBox.YESNO,
						icon: Ext.MessageBox.QUESTION,
						fn: function(btn){
							if (btn == 'yes')
							{	
								Ext.getBody().mask("系统正在更新系统菜单权限，请稍候...", "x-mask-loading");
								this.OpCmd = App.Base.common.param.OP_CMD_GENERATE;
								this.doRequest();
							}
						},
						scope: this
					});	
				},
				scope: this
			}, '-', {
				id: 'tbarMenusAdd' + this.MODULE_ID,
				text:'<font color="#0000E3">新增菜单项</font>',
				iconCls: 'x-menu-personinfolist-add',
				//tooltip: {title:'Tip Title', text:'This is a an example QuickTip for a toolbar item'},
				//enableToggle: true,
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_ADD;
					this.doRequest();
				},
				scope: this
				}, '-', {
				id: 'tbarMenusModify' + this.MODULE_ID,
				text:'<font color="#0000E3">修改菜单项</font>',
				iconCls: 'x-menu-systemmenusmanage-modify',
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_MODIFY;
					this.doRequest();
				},
				scope: this
				}, '-', {
				id: 'tbarMenusDelete' + this.MODULE_ID,
				text:'<font color="#0000E3">删除菜单项</font>',
				iconCls: 'x-menu-personinfolist-delete',
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_DELETE;
					this.createSysSelUpMenusWin();
				},
				scope: this
				}, '-', {
				id: 'tbarMenusReset' + this.MODULE_ID,
				text:'<font color="#0000E3">重置表单</font>',
				iconCls: 'x-menu-systemmenusmanage-rset',
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_NONE;
					this.form.getForm().reset();
					},
				scope: this
				},'-'
			]
		}),

		layout: 'border',

		items: [{
			region:'west',
			id: 'formWest' + this.MODULE_ID,

			title : '系统菜单目录树',
			width : 240,
			minWidth: 220,
			border: false,
			autoScroll: true,

			split : true,
			collapsible : true,
			bodyStyle:'padding:5px 5px 5px 0',

			layout: 'fit',
			items: [this.tree]
		},{
			region:'center',
			id: 'formCenter' + this.MODULE_ID,

			frame: true,
			border: false,
			autoScroll: true,

			defaults: {width: 620},
			defaultType: 'textfield',

			labelAlign: 'top',
			labelWidth: 128,
			bodyStyle:'padding:5px 5px 5px 0',

			layout: 'form',
			items :[{
				id: 'menuName' + this.MODULE_ID,
				name: 'menuName' + this.MODULE_ID,
				fieldLabel: '<font color="#FF0000">菜单项名称(必填)</font>',
				maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
				regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
				regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
				allowBlank: false
			},
			new Ext.Button({
				id: 'btnSelectSysMenusParentMenu' + this.MODULE_ID,
				text: '<font color="#FF0000">选择上级菜单项(必选)</font>',

				handler: function(){
					this.createSysSelUpMenusWin();
				},
				scope: this
			})
			, {
				id: 'menuParentId' + this.MODULE_ID,
				name: 'menuParentId' + this.MODULE_ID,
				fieldLabel: '<font color="#FF0000">上级菜单项ID' + App.Base.common.param.SPLIT_CHARS_UNDELINE + '名称(必填)</font>',
				readOnly: true,
				disabled: true,
				hideLabel: true,
				maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
				regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
				regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
				allowBlank: false,
				emptyText : '请选择上级菜单项...'
			}, {
				id: 'menuDesc' + this.MODULE_ID,
				name: 'menuDesc' + this.MODULE_ID,
				fieldLabel: '<font color="red">菜单项描述</font>',
				maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
				regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
				regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS
			}, {
				xtype: 'fieldset',
				id: 'fieldset01' + this.MODULE_ID,
				title: '菜单项创建为菜单节点',
				collapsible: true,
				collapsed: false,
				autoHeight: true,
				
				labelAlign: 'top',
				labelWidth: 128,
				layout: 'form',
				items: [{
					xtype: 'checkbox',
					id: 'leafNodeFlag' + this.MODULE_ID,
					name: 'leafNodeFlag' + this.MODULE_ID,
					hideLabels: true,
					fieldLabel: '<font color="red">请选择</font>',
					boxLabel: '<font color="red">创建为菜单节点</font>',
					listeners: {
						check: function(checkbox, checked){
							var o1 = Ext.getCmp('menuNavUrl' + this.MODULE_ID);
							var o2 = Ext.getCmp('expandImgUrl' + this.MODULE_ID);

							if (checked)
							{
								o1.setDisabled(false);
								o2.setDisabled(true);
								o2.setRawValue('');
								//o1.focus();
							}
							else 
							{
								o2.setDisabled(false);
								o1.setDisabled(true);
								o1.setRawValue('');
								//o2.focus();
							}
						},
						scope: this
					}
				}, {
					xtype: 'textfield',
					id: 'menuNavUrl' + this.MODULE_ID,
					name: 'menuNavUrl' + this.MODULE_ID,
					width: 596,
					fieldLabel: '<font color="#FF0000">菜单节点项执行的命令配置(如果是创建菜单节点，必填)</font>',
					maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
					regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
					regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
					disabled: true
				}, {
					xtype: 'textfield',
					id: 'expandImgUrl' + this.MODULE_ID,
					name: 'expandImgUrl' + this.MODULE_ID,
					width: 596,
					fieldLabel: '<font color="#FF0000">非菜单节点项在目录树展开时的图标URL路径(如果是创建非菜单节点，必填)</font>',
					maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
					regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
					regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS
				}]
			}, {
				xtype: 'fieldset',
				id: 'fieldset02' + this.MODULE_ID,
				title: '菜单项配置',
				collapsible: true,
				collapsed: false,
				autoHeight: true,
				
				labelAlign: 'top',
				labelWidth: 128,
				layout: 'form',
				items: [{
					xtype: 'checkbox',
					id: 'menuDisplayFlag' + this.MODULE_ID,
					name: 'menuDisplayFlag' + this.MODULE_ID,
					hideLabels: true,
					checked: true,
					fieldLabel: '<font color="red">菜单项是否显示</font>',
					boxLabel: '<font color="red">是</font>'
				}, {
					xtype: 'textfield',
					id: 'normalImgUrl' + this.MODULE_ID,
					name: 'normalImgUrl' + this.MODULE_ID,
					width: 596,
					fieldLabel: '<font color="red">菜单项在目录树中显示的正常图标URL路径(必填)</font>',
					maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
					regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
					regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
					allowBlank: false
				}, {
					xtype: 'textfield',
					id: 'displayRankIndex' + this.MODULE_ID,
					name: 'displayRankIndex' + this.MODULE_ID,
					value: '0',
					width: 596,
					fieldLabel: '<font color="#FF0000">菜单项在目录树中显示先后顺序的排序序号值(必填 菜单目录树为降序排列，数值大的将排在前面)</font>',
					regex: /^-?\d+$/,
					regexText:"只能够输入数字(最多16位)", 
					maxLength: 16, 
					allowBlank: false
				}, {
					xtype: 'checkbox',
					id: 'sysHoldFlag' + this.MODULE_ID,
					name: 'sysHoldFlag' + this.MODULE_ID,
					hideLabels: true,
					fieldLabel: '<font color="red">菜单项是否标记为系统菜单项</font>',
					boxLabel: '<font color="red">是</font>'
				}]
			}]
		}],
		listeners: {
			beforedestroy: function(o){
			},
			scope: this
		}
	});

	this.form.doLayout();

	//defined methods.
    if((typeof App.Base.SystemManage.SystemMenusManage.SIMULATE_SHARED_METHODS_FLAG) == "undefined")
    {
        App.Base.SystemManage.SystemMenusManage.SIMULATE_SHARED_METHODS_FLAG = true;   

        App.Base.SystemManage.SystemMenusManage.prototype.getMainPanel = function(){   
            return this.form;  
        };
 
        //simulating the class's constructor().
        var __ctor = function(){
            //alert('called __constructor() ok.');
        }();

    }
}